package errgroup

import (
	"errors"
	"fmt"
	group "golang.org/x/sync/errgroup"
)

type Group struct {
	group.Group
}

func (g *Group) Go(f func() error) {

	var f2 = func() (err error) {

		defer func() {
			if r := recover(); r != nil {

				switch e := r.(type) {
				case error:
					err = e
				case string:
					err = errors.New(e)

				default:
					err = fmt.Errorf("%v", e)
				}
			}
		}()

		return f()
	}

	g.Group.Go(f2)
}
